//-------------------------------------------------------------------------------------------------
// <copyright file="SA1501.cs" company="OfficeClip LLC">
// Copyright (c) OfficeClip LLC.  All rights reserved.
// </copyright>
//-------------------------------------------------------------------------------------------------

namespace OfficeClip.OpenSource.StyleFix.Drivers
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Text.RegularExpressions;

    public class SA1500
    {
        public static string Run(string input)
        {
            string outputLine = input.TrimEnd();
            // First check for the starting {
            Regex reg = new Regex(@"^(\s+)(\{|\})(.+)$");
            Match m = reg.Match(outputLine);
            if (m.Success)
            {
                outputLine = string.Format(
                 @"{0}{1}{2}{0}    {3}",
                 m.Groups[1].Value,
                 m.Groups[2].Value,
                 System.Environment.NewLine,
                 m.Groups[3].Value.Trim());
            }
            // Now check the ending braces }
            reg = new Regex(@"^(\s+)(.+)(\{|\})$");
            m = reg.Match(outputLine);
            if (m.Success)
            {
                outputLine = string.Format(
                 @"{0}{1}{2}{3}",
                 m.Groups[1].Value,
                 m.Groups[2].Value,
                 System.Environment.NewLine,
                 m.Groups[3].Value);
            }
            return outputLine;
        }
    }
}
